<template>
  <div class="topic">
    <ul>
      <li v-for="item in datArr" :key="item.id">
        <img v-lazy="item.scene_pic_url" alt="" />
        <h4>{{ item.title }}</h4>
        <p>{{ item.subtitle }}</p>
        <p class="moey">{{ item.price_info | formatMoey }}</p>
      </li>
    </ul>
    <van-pagination
      v-model="page"
      :page-count="pagecount"
      mode="simple"
      @change="changepage"
    />
  </div>
</template>

<script>
import { getTopicData } from "@/utils/http";
export default {
  name: "Topic",
  data() {
    return {
      page: 1, //默认当前数
      size: 10, //默认每页的数据
      datArr: [], //当前页面的数据
      pagecount: 0,
    };
  },
  created() {
    //初始化请求数据
    this.getData();
  },
  methods: {
    changepage() {
      console.log(this.page); //输出当前页
      this.getData();

      //重新请求数据
    },
    getData() {
      getTopicData({
        page: this.page,
        size: this.size,
      }).then((res) => {
        console.log(res);
        const { data, currentPage, totalPages } = res.data.data;
        this.datArr = data;
        this.page = currentPage;
        this.pagecount = totalPages;
      });
    },
  },
};
</script>

<style lang='less' scoped>
.topic {
  img {
    width: 100%;
    display: block;
  }
  h4 {
    font-size: 8px;
    font-weight: 400;
    text-align: center;
    margin-top: 10px;
  }
  p {
    font-size: 8px;
    font-weight: 400;
    text-align: center;
    margin-top: 8px;
    margin-bottom: 8px;
  }
  .moey {
    color: #9b0000;
  }
}
/deep/.van-pagination__page-desc{
    display: none;
}
</style>